/*
 * Copyright 2020-2025 the original author or authors.
 * You cannot use this file unless authorized by the author.
 */

package org.ipig.mata.table;

import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.builder.ToStringBuilder;

import static org.apache.commons.lang3.builder.ToStringStyle.DEFAULT_STYLE;

/**
 * 字段信息
 *
 * @author <a href="mailto:comchnts@163.com">chinats</a>
 * @version $$Id: ColumnMeta.java 3 2020-01-21 09:36:33Z ts <comchnts@163.com> $$
 * @since 1.0
 */
@Data
public class ColumnMeta implements Cloneable {
    private String name;
    private int type;

    /**
     *
     */
    public ColumnMeta() {
    }

    /**
     * @param columnName
     * @param columnType
     */
    public ColumnMeta(String columnName, int columnType) {
        this.name = StringUtils.upperCase(columnName);// 统一为大写
        this.type = columnType;
    }


    public void setName(String name) {
        this.name = StringUtils.upperCase(name);// 统一为大写
    }


    public ColumnMeta clone() {
        try {
            super.clone();
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }
        return new ColumnMeta(this.name, this.type);
    }

    public String toString() {
        return ToStringBuilder.reflectionToString(this, DEFAULT_STYLE);
    }
}
